<!DOCTYPE html>
<html class="x-admin-sm">
  <head>
      <meta charset="UTF-8">
      <title>快件列表</title>
      <meta name="renderer" content="webkit">
      <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
      <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
      <link rel="stylesheet" href="css/font.css">
      <link rel="stylesheet" href="css/xadmin.css">
      <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
      <script type="text/javascript" src="lib/layui/layui.js" charset="utf-8"></script>
      <script type="text/javascript" src="js/xadmin.js"></script>
      <script type="text/javascript" src="js/cookie.js"></script>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  </head>
  <body>
      <script>
          $(function(){
              $("#submit").click(function () {
                  var str="http://localhost:8080/es/list";
                  var property=$("#select").val();
                  var inputValue=$("#input").val();
                  $.ajax({
                      url:str,
                      type:"post",
                      dataType:'JSON',
                      data:"{\"" + property + "\":" + inputValue + "}",
                      contentType : "application/json; charset=utf-8",
                      success:function(data){
                          var obj = data;
                          if(obj.code.code === 0){
                              var list=obj.esList;
                              $("#numspan").text("显示数据："+list.length+"条");
                              var tableData;
                              for(var i=0;i<list.length;i++){
                                  var str="<td class='td-manage'>"+
                                      '<a title="编辑"  href="javascript:;"  onclick="x_admin_show( \'编辑\',\'express-edit.html?Data='+list[i].id+'\',600,400)">'+
                                      "<i class=\"layui-icon\">&#xe642;</i>" +
                                      "</a>" +
                                      '<a title="删除" href="javascript:;" onclick="express_del(this,'+list[i].id+')">'+
                                      "<i class='layui-icon'>&#xe640;</i> " +
                                      "</a> "+
                                      '<a title="位置信息" href="javascript:;" onclick="x_admin_show( \'详情\',\'express-location.html?Data='+list[i].id+'\',900,600)">'+
                                      "<i class='layui-icon'>&#xe60f;</i> " +
                                      "</a> "+
                                      "</td>";
                                  tableData+="<tr> " +
                                      "<td>"+list[i].id +"</td> " +
                                      "<td>"+list[i].type +"</td> " +
                                      "<td>"+list[i].sender.name +"</td>" +
                                      "<td>"+list[i].recever.name +"</td>" +
                                      "<td>"+list[i].weight +" </td>" +
                                      "<td>"+list[i].tranFee +"</td>" +
                                      "<td>"+list[i].packageFee +"</td>" +
                                      "<td>"+list[i].insuFee +"</td> "+
                                      "<td>"+list[i].accepter +"</td> "+
                                      "<td>"+list[i].deliver +"</td> "+
                                      "<td>"+list[i].accepteTime +"</td> "+
                                      "<td>"+list[i].deliveTime +"</td> "+
                                      "<td>"+list[i].acc1 +"</td> "+
                                      "<td>"+list[i].acc2 +"</td> "+
                                      "<td>"+list[i].status +"</td> "+str+
                                      "</tr>";
                              }
                              $("#firsttbody").html(tableData);
                          }
                          else{
                              alert(obj.code.message);
                          }
                      },
                      error:function(){
                          alert("error");
                      }
                  });
              });
          });
      </script>
      <div class="x-nav">
          <span class="layui-breadcrumb">
              <a href="">快件列表</a>
          </span>
          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
              <i class="layui-icon" style="line-height:30px">刷新</i>
          </a>
      </div>
      <div class="x-body">
          <div class="layui-row">
              <form class="layui-form layui-col-md12 x-so" method="#">
                  <div class="layui-input-inline" style="margin-left: 380px">
                      <select id="select">
                          <option value="id">按快递单号搜索</option>
                          <option value="sender">按寄件人编号搜索</option>
                          <option value="recever">按收件人编号搜索</option>
                          <option value="accepter">按揽收人搜索</option>
                          <option value="deliver">按交付人搜索</option>
                          <option value="status">按快递状态搜索</option>
                      </select>
                  </div>
                  <!--<div class="layui-input-inline">-->
                      <!--<select id="selectway">-->
                          <!--<option value="eq">等值查找</option>-->
                          <!--<option value="like">模糊查找</option>-->
                      <!--</select>-->
                  <!--</div>-->
                  <input id="input" class="layui-input" type="text" name="customername" placeholder="请输入选中的搜索方式" autocomplete="off" value="">
                  <button class="layui-btn" id="submit" type="button"><i class="layui-icon">&#xe615;</i></button>
              </form>
          </div>
          <xblock>
              <button class="layui-btn" onclick="x_admin_show('新建快件','./express-add.html',600,400)"><i class="layui-icon"></i>添加</button>
              <button class="layui-btn" onclick="x_admin_show('查询包裹快件','./express-search.html',1300,400)"><i class="layui-icon"></i>查询快件</button>
              <span id="numspan" class="x-right" style="line-height:40px">共有数据：0 条</span>
          </xblock>
          <table class="layui-table">
              <thead>
                  <tr>
                      <th>快递单号</th>
                      <th>类型</th>
                      <th>寄件人</th>
                      <th>收件人</th>
                      <th>重量</th>
                      <th>运费</th>
                      <th>包装费</th>
                      <th>保险费</th>
                      <th>揽收人</th>
                      <th>交付人</th>
                      <th>揽收时间</th>
                      <th>交付时间</th>
                      <th>寄件附件</th>
                      <th>收件附件</th>
                      <th>快递状态</th>
                  </tr>
              </thead>
              <tbody id="firsttbody">

              </tbody>
          </table>
          <!--<div class="page">-->
              <!--<div>-->
                  <!--<a class="prev" href="">&lt;&lt;</a>-->
                  <!--<a class="num" href="">1</a>-->
                  <!--<a class="next" href="">&gt;&gt;</a>-->
              <!--</div>-->
          <!--</div>-->
      </div>
      <script>
          /*用户-删除*/
          function express_del(obj,id){
              layer.confirm('确认要删除吗？',function(){
                  //发异步删除数据
                  var str="http://localhost:8080/es/delete/"+id;
                  $.ajax({
                      url:str,
                      type:"GET",
                      dataType:'JSON',
                      contentType : "application/json; charset=utf-8",
                      success:function(data){
                          if(data.code === 0){
                              $(obj).parents("tr").remove();
                              alert("删除成功");
                          }
                          else{
                              alert(data.code.message);
                          }
                      },
                      error:function(){
                          alert("error");
                      }
                  });
              });
          }
      </script>
  </body>
</html>